@extends('default.layouts.adminPublic')
@section('title', '修改合同')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/vendor/jedate/skin/jedate.css')}}">
    <link rel="stylesheet" href="{{asset('/default/css/admin/indexList.css')}}">
    <style>
        .wicon{ background-image:url("");
            background-repeat:no-repeat; background-position:right center; cursor:pointer; }
    </style>
    @endsection
    @section('content')
            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/contract_index')}}">首页</a> &raquo; 合同管理
    </div>
    <!--导航结束-->
    <!--结果集标题与导航组件 开始-->
    <div class="con">

        <div class="conMain">
            <div class="manage" style="color:#999"><p>注：修改用户信息资料只能在用户注册信息里面修改.</p></div>
            <div class="manage"><h1>修改合同</h1></div>
            <div class="conInfo">
                <div class="manage" style="padding: 0; margin-bottom: 10px;">
                    @if(count($errors)>0)
                        <div class="mark">
                            @if(is_object($errors))
                                @foreach($errors->all() as $error)
                                    <p>{{$error}}</p>
                                @endforeach
                            @else
                                <p>{{$errors}}</p>
                            @endif
                        </div>
                    @endif
                </div>
                <div class="conAddList">
                    <form action="{{url('admin/contract/'.$company_contract->id)}}" method="post" name="contractForm"
                          onsubmit="return checkForm('#contractForm')" id="contractForm">
                        <input type="hidden" name="uid" value="{{$company_contract->uid}}">
                        <input type="hidden" name="_method" value="put">
                        {{csrf_field()}}
                        <dl>
                            <dt><i class="require">*</i>服务类别：</dt>
                            <dd>
                                <select name="category" id="category" style="width:160px;">
                                    <option value="">请选择</option>
                                    @if(count($vip_package) > 0)
                                        @foreach($vip_package as $v )
                                            <option value="{{$v->id}}">{{$v->vipname}}</option>
                                        @endforeach
                                    @endif
                                </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>服务时间：</dt>
                            <dd>
                                <input class="wicon" name="start_time" style="width:180px;" id="start_time"
                                       value="{{$company_contract->start_time}}" type="text" readonly>
                                <span>~</span>
                                <input class="wicon" name="end_time" style="width:180px;" id="end_time"
                                       value="{{$company_contract->end_time}}" type="text" readonly>
                            </dd>
                        </dl>

                        <dl>
                            <dt>会员内简历数：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;"
                                       value="{{$company_contract->vip_resume_number}}" name="vip_resume_number"
                                       id="vip_resume_number"></dd>
                        </dl>

                        <dl>
                            <dt>会员期内积分：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;"
                                       value="{{$company_contract->vip_integral}}" name="vip_integral"
                                       id="vip_integral"></dd>
                        </dl>
                        <dl>
                            <dt>会员内职位数：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;" name="vip_post_number"
                                       value="{{$company_contract->vip_post_number}}" id="vip_post_number"></dd>
                        </dl>
                        <dl>
                            <dt>非会员简历数：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;"
                                       value="{{$company_contract->resume_number}}" name="resume_number"
                                       id="resume_number"></dd>
                        </dl>
                        <dl>
                            <dt>非会员积分：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;"
                                       value="{{$company_contract->integral}}" name="integral" id="integral"></dd>
                        </dl>
                        <dl>
                            <dt>启停次数：</dt>
                            <dd><input type="text" class="inpText" style="width:140px;" value="{{$company_contract->stop_number}}"
                                       name="stop_number" id="stop_number">
                                <span style="margin-left:20px; color:#ff4400">注：只填写纯数字，设置后可以开启启停功能</span>
                            </dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>销售代表：</dt>
                            <dd>
                                <select name="responsible_crm_uid" id="responsible_crm_uid" style="width:160px;">
                                    <option value="">请选销售代表</option>
                                    @if(count($crmUser) > 0)
                                        @foreach($crmUser as $v )
                                            <option value="{{$v->uid}}">{{$v->worker_name}}</option>
                                        @endforeach
                                    @endif
                                    <option value="0">其他</option>
                                </select>
                            </dd>
                            {{--<input type="text" class="inpText" value="{{$company_contract->responsible}}" name="responsible" id="responsible">--}}
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>支付方式：</dt>
                            <dd>
                                <select name="pay" id="pay" style="width:160px;">
                                    <option value="">请选择收款方式</option>
                                    @if(count($pay) > 0)
                                        @foreach($pay as $v )
                                            <option value="{{$v->opt_id}}">{{$v->opt_name}}</option>
                                        @endforeach
                                    @endif
                                </select>
                            </dd>
                        </dl>
                        <dl>
                            <dt>收费金额：</dt>
                            <dd><input type="text" class="inpText" value="{{$company_contract->money}}" name="money"
                                       id="money"></dd>
                        </dl>
                        <dl>
                            <dt><i class="require">*</i>支付时间：</dt>
                            <dd>
                                <input class="wicon" name="pay_time" value="{{$company_contract->pay_time}}"
                                       style="width:220px;" id="pay_time" type="text" readonly>
                            </dd>
                        </dl>
                        <dl style="height: 100px;">
                            <dt style="height: 100px;">备注：</dt>
                            <dd style="height: 100px;"><textarea name="remark" id="remark"
                                                                 style="height: 68px; width: 600px;">{{$company_contract->remark}}</textarea>
                            </dd>
                        </dl>
                        <dl>
                            <dt>添加时间：</dt>
                            <dd>{{$company_contract->created_at}}</dd>
                        </dl>
                        <dl>
                            <dt></dt>
                            <dd>
                                <input name="c_type" id="c_type1"  style="width: 16px; height: 16px; margin: 0px;" type="radio" value="1" checked>
                                <label for="c_type1">只修改合同信息</label>
                                <input name="c_type"  id="c_type2" style="width: 16px; height: 16px; margin: 0px; "  type="radio" value="2">
                                <label for="c_type2">同步会员信息</label>
                            </dd>
                        </dl>
                        <dl>
                            <dt></dt>
                            <dd>
                                <input type="submit" class="sub" value="修改合同">
                                <input type="button" class="sub but" onclick="history.go(-1)" value="返回">
                            </dd>
                        </dl>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
@endsection

@section('footerjs')
    @parent
    <script type="text/javascript" src="{{asset('/vendor/jedate/jquery.jedate.min.js')}}"></script>
    <script>

        $(function(){
            var contractForm = $('#contractForm');
            contractForm.find('#category').val('{{$company_contract->category}}');
            contractForm.find('#pay').val('{{$company_contract->pay}}');

            contractForm.find('#category').bind("change", function(){
                if($(this).val() == ''){
                    layer.msg('套餐类型必须选择，为您选中当前套餐类型');
                    var id = '{{$company_contract->category}}';
                    contractForm.find('#category').val(id);
                }else{
                    var id = $(this).val();
                }
                $.post("/admin/change_vip", {'id': id, '_token': "{{csrf_token()}}"}, function(data){
                    contractForm.find('#start_time').val(data.start_time);
                    contractForm.find('#end_time').val(data.end_time);
                    contractForm.find('#vip_resume_number').val(data.vip_resume_number);
                    contractForm.find('#vip_integral').val(data.vip_integral);
                    contractForm.find('#vip_post_number').val(data.vip_post_number);
                    contractForm.find('#resume_number').val(data.resume_number);
                    contractForm.find('#integral').val(data.integral);
                    contractForm.find('#money').val(data.money);
                });
            });

            //销售代表
            contractForm.find('#responsible_crm_uid').val('{{$company_contract->responsible_crm_uid}}');
            if(contractForm.find('#responsible_crm_uid').val() == '0'){
                addresponsible(contractForm.find('#responsible_crm_uid'));
            }
            //添加销售负责人
            contractForm.find('#responsible_crm_uid').bind("change", function(){
                addresponsible($(this));
            });
        });
        function addresponsible($this){
            if($this.val() == '0'){
                var str = '';
                str += '<span class="addresponsible"><input type="text" style="width:160px;" name="responsible" value="{{$company_contract->responsible}}" id="responsible" placeholder="请填写销售负责人"></span>';
                $this.after(str);
            }else{
                $this.parents('dl').find('.addresponsible').remove();
            }
        }
        //蓝色风格
        $.jeDate('#start_time', {
            format: 'YYYY-MM-DD hh:mm:ss',
            festival: true
        });
        $.jeDate('#end_time', {
            format: 'YYYY-MM-DD hh:mm:ss',
            festival: true
        });
        $.jeDate('#pay_time', {
            format: 'YYYY-MM-DD hh:mm:ss',
            isinitVal:true,                            //是否初始化时间，默认不初始化时间
            festival: true
        });
    </script>
@endsection

